<template>
    <div class="jobcommon zhiweimiaoshu EditResumeInfo">
        <div class="popBody">
            <div class="backnavjob">
                <h1 @click="closejibenxinxi('close')">
                    <img
                        data-v-61dd7a3d=""
                        src="../../assets//newimg/index/icon_right_h.png"
                        alt=""
                    />
                </h1>
                <h2>
                    <span>职位亮点</span>
                </h2>
                <h3></h3>
            </div>
        </div>
        <div class="edittag">
            <div class="tit font12">
                最多可以选6项
                <div class="J_more more for-event">换一批</div>
            </div>
            <div id="J_tagWrap">
                <div class="J_tagPage">
                    <div
                        class="tag"
                        :class="{ select: item.key }"
                        v-for="(item, index) in tarList"
                        :key="index"
                        @click="item.key = !item.key"
                    >
                        {{ item.name }}
                    </div>
                </div>
            </div>
            <div class="clear"></div>
            <div class="tagbtns">
                <div id="J_savetag" class="qs-btn qs-btn-blue font18">保存</div>
            </div>
        </div>
        <div class="j_newbutton">
            <div class="j_newbtn" @click="closejibenxinxi()">保存</div>
        </div>
    </div>
</template>

<script>
// import { axiosPost } from '../../axios';
// import { Toast } from 'vant';
export default {
    name: '',
    props: ['tag_arr', 'tag', 'tag_cn'],
    data() {
        return {
            tarList: [],
        };
    },
    computed: {},
    mounted() {
        // 加工数据
        for (let i in this.tag_arr) {
            let item = {
                id: i,
                name: this.tag_arr[i],
                key: false,
            };
            if (this.tag.length > 0) {
                if (this.tag.split(',')) {
                    for (let j in this.tag.split(',')) {
                        if (this.tag.split(',')[j] === i) {
                            item.key = true;
                        }
                    }
                } else {
                    if (i == this.tag) {
                        item.key = true;
                    }
                }
            }
            this.tarList.push(item);
        }
    },
    methods: {
        closejibenxinxi(type) {
            if (type) {
                this.$emit('closeProps', { type: 2, key: false });
                return;
            }
            this.$emit('closeProps', {
                type: 2,
                key: true,
                data: {
                    tag: this.tarList
                        .filter((el) => el.key)
                        .map((el) => el.id)
                        .join(','),
                    tag_cn: this.tarList
                        .filter((el) => el.key)
                        .map((el) => el.name)
                        .join(','),
                },
            });
        },
    },
};
</script>

<style lang="less" scope>
.edittag {
    overflow: hidden;
}
</style>
